package com.etb.wisdom.eframe.rights.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import com.etb.web.action.ETBAction;
import com.etb.web.action.Token;
import com.etb.web.eui.utils.EuiUtil;
import com.etb.wisdom.eframe.model.EtbRole;
import com.etb.wisdom.eframe.rights.service.EtbRoleService;

@Action("role")
@Namespace("/eframe/rights/etbrole")
public class EtbRoleAction extends ETBAction<EtbRole> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1115945472778197080L;
	
	@Autowired
	private EtbRoleService roleService;
	
	public void getAllOrg() {
		String roleId = request.getParameter("roleId");
		EuiUtil.toTree(roleService.getAllOrg(roleId));
	}
	
	public void getAllPosi() {
		String roleId = request.getParameter("roleId");
		EuiUtil.toTree(roleService.getAllPosi(roleId));
	}
	
	public void getAllEmp() {
		String roleId = request.getParameter("roleId");
		EuiUtil.toTree(roleService.getAllEmp(roleId));
	}

	@Token
	public void saveRes() {
		String addFuncIds = request.getParameter("addFuncIds");
		String delFuncIds = request.getParameter("delFuncIds");
		String roleId = request.getParameter("roleId");
		roleService.saveFunc(roleId, addFuncIds, delFuncIds);
	}
	
	public void saveEmp() {
		String addEmpIds = request.getParameter("addEmpIds");
		String delEmpIds = request.getParameter("delEmpIds");
		String roleId = request.getParameter("roleId");
		roleService.saveEmp(roleId, addEmpIds, delEmpIds);
	}
	
	public void savePosi() {
		String addPosiIds = request.getParameter("addPosiIds");
		String delPosiIds = request.getParameter("delPosiIds");
		String roleId = request.getParameter("roleId");
		roleService.savePosi(roleId, addPosiIds, delPosiIds);
	}
	
	public void saveOrg() {
		String addOrgIds = request.getParameter("addOrgIds");
		String delOrgIds = request.getParameter("delOrgIds");
		String roleId = request.getParameter("roleId");
		roleService.saveOrg(roleId, addOrgIds, delOrgIds);
	}
}